from django.db import models

# Create your models here.
class Cate(models.Model):
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=20)
    class Meta:
        db_table='tb_cate'
    def __str__(self):
        return self.name
class Book(models.Model):
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=20)
    sale = models.IntegerField()
    price = models.DecimalField(max_digits=4,decimal_places=2)
    date = models.DateField()
    cate = models.ForeignKey(to='Cate',on_delete=models.CASCADE)
    class Meta:
        db_table='tb_book'
    def __str__(self):
        return self.name